package pt.uma.gap.ast;



import java.util.ArrayList;
import java.util.List;

import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;

import pt.uma.gap.graph.GraphNode;

public class DeclarationASTInfo {

	private VariableDeclarationFragment variableDeclarationFragment;
	private VariableDeclarationStatement variableDeclarationStatement ;
	private FlowType declarationType  = FlowType.UNDEFINED;
	
	private List<MethodInvocation> methodInvocationList;
	private GraphNode graphNodeRef;


	public void addVariableDeclarationFragment(VariableDeclarationFragment node){
		variableDeclarationFragment = node;
	}
	
	
	public void addVariableDeclarationStatement(VariableDeclarationStatement node){
		variableDeclarationStatement = node;
	}


	public VariableDeclarationFragment getVariableDeclarationFragment() {
		return variableDeclarationFragment;
	}


	public VariableDeclarationStatement getVariableDeclarationStatement() {
		return variableDeclarationStatement;
	}

	public FlowType getDeclarationType() {
		return declarationType;
	}


	public void setDeclarationType(FlowType declarationType) {
		this.declarationType = declarationType;
	}

	public void addMethodInvocation(MethodInvocation methodInvocation) {
		if(this.methodInvocationList == null){
			this.methodInvocationList = new ArrayList<MethodInvocation>(1);
		}
		this.methodInvocationList.add(methodInvocation);
	}


	public List<MethodInvocation> getMethodInvocationList() {
		return methodInvocationList;
	}

	public int getMethodInvocationListSize(){
		if(methodInvocationList == null){
			return 0;
		}else{
			return methodInvocationList.size();
		}
	}

	public String getName() {
		return variableDeclarationFragment.getName().toString();
	}


	public String getType() {
		return variableDeclarationStatement.getType().toString();
	}


	public String getInitializer() {
		if(variableDeclarationFragment.getInitializer() != null){
			return variableDeclarationFragment.getInitializer().toString();
		}else{
			return null;
		}
	}





	public void setGraphNodeRef(GraphNode graphNodeRef) {
		this.graphNodeRef = graphNodeRef;
	}


	public GraphNode getGraphNodeRef() {
		return graphNodeRef;
	}



	

	

}
